<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Aria: dpptuExample.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Aria
   &#160;<span id="projectnumber">2.9.4</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('dpptuExample_8cpp-example.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">dpptuExample.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>Shows how to control the Directed Perception pan-tilt unit using <a class="el" href="classArDPPTU.html" title="Driver for the DPPTU. ">ArDPPTU</a> class directly. This program lets you use the keyboard to control the DPPTU. It uses the same acceleration and slew rates for the pan and tilt axes.</p>
<p>It is also possible to specify the type of PTU in program configuration (in the ARIA robot parameter files or program command-line arguments) instead. For an example of that, see cameraPTZExample.cpp instead.</p>
<p>Commands: </p><hr/>
<p>UP,DOWN &ndash; tilt up/down by one positional increment LEFT,RIGHT &ndash; pan left/right by one positional increment SPACE &ndash; perform reset calibration I &ndash; initialize PTU to default settings &lt;,&gt; &ndash; increase/decrease the posIncrement by 0.5 degree +,- &ndash; increase/decrease the speed by 1 degree/sec A &ndash; awaits the completion of last issued positional command R &ndash; change pan/tilt movements to relative or absolute movements Z &ndash; move pan and tilt axes to zero 1 &ndash; move to stored position 1 (-90, 0) 2 &ndash; move to stored position 2 (90, 0) 3 &ndash; move to stored position 3 (0, -45) 4 &ndash; move to stored position 4 (0, 30) M &ndash; Enter or Exit monitor (continuous scan) mode H &ndash; Halt all motion S &ndash; print current variable values ESC &ndash; quit</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;Aria.h&quot;</span></div><div class="line"></div><div class="line"><span class="comment">// If defined, use this computer serial port. If not defined, use first robot</span></div><div class="line"><span class="comment">// aux. serial port.  Most robots have the DPPTU on COM2 if on Linux and COM4 on</span></div><div class="line"><span class="comment">// Windows, if not equipped with other accessories which might require those</span></div><div class="line"><span class="comment">// ports (e.g. GPS or Laser).</span></div><div class="line"><span class="preprocessor">#define SERIAL_PORT_WITH_ROBOT ArUtil::COM4</span></div><div class="line"><span class="preprocessor">#define SERIAL_PORT_WITHOUT_ROBOT ArUtil::COM1</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// Determines type of DPPTU to set internal conversion factors. See enum of</span></div><div class="line"><span class="comment">// types in ArDPPTU class for possible values.</span></div><div class="line"><span class="comment">//#define PTU_TYPE ArDPPTU::PANTILT_PTUD46</span></div><div class="line"></div><div class="line"><span class="comment">// by how much the &lt; and &gt;  keys change the position command increment in this</span></div><div class="line"><span class="comment">// example</span></div><div class="line"><span class="preprocessor">#define POS_INC_ADJUSTMENT 1</span></div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  This class is the core of this demo, it adds itself to the robot given</span></div><div class="line"><span class="comment">  as a user task, and contains key handler callbacks to control the PTU.</span></div><div class="line"><span class="comment">*/</span></div><div class="line"><span class="keyword">class </span>KeyPTU</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line">  <span class="comment">// constructor</span></div><div class="line">  KeyPTU(<a name="_a0"></a><a class="code" href="classArRobot.html">ArRobot</a> *robot, <span class="keyword">const</span> <span class="keywordtype">char</span> *port);</div><div class="line">  ~KeyPTU(<span class="keywordtype">void</span>);</div><div class="line">  </div><div class="line">  <span class="keywordtype">void</span> up(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> down(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> left(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> right(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> space(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> i(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> plus(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> minus(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> greater(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> less(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> question(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> status(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> a(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> m(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> h(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> r(<span class="keywordtype">void</span>);</div><div class="line">  <span class="keywordtype">void</span> gotoPos(<span class="keywordtype">double</span> p, <span class="keywordtype">double</span> t);</div><div class="line"></div><div class="line">  <span class="comment">// the callback function</span></div><div class="line">  <span class="keywordtype">void</span> drive(<span class="keywordtype">void</span>);</div><div class="line"></div><div class="line"><span class="keyword">protected</span>:</div><div class="line">  <span class="keywordtype">int</span> myPanValPTU;</div><div class="line">  <span class="keywordtype">int</span> myTiltValPTU;</div><div class="line"></div><div class="line">  <span class="keywordtype">int</span> myDesiredPanPos;</div><div class="line">  <span class="keywordtype">int</span> myDesiredTiltPos;</div><div class="line">  <span class="keywordtype">int</span> mySlew;</div><div class="line">  <span class="keywordtype">int</span> myPosIncrement;</div><div class="line">  <span class="keywordtype">int</span> mySlewIncrement;</div><div class="line"></div><div class="line">  <span class="keywordtype">int</span> POS_INCREMENT_ADJUSTMENT;</div><div class="line"></div><div class="line">  <span class="keywordtype">bool</span> myMonitor;</div><div class="line">  <span class="keywordtype">bool</span> myReset;</div><div class="line">  <span class="keywordtype">bool</span> myInit;</div><div class="line">  <span class="keywordtype">bool</span> myAbsolute;</div><div class="line"></div><div class="line">  <a name="_a1"></a><a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myUpCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myDownCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myLeftCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myRightCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> mySpaceCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myICB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myPlusCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myMinusCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myGreaterCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myLessCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myQuestionCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> mySCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myACB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myMCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myHCB;</div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myRCB;</div><div class="line">  <a name="_a2"></a><a class="code" href="classArFunctor2C.html">ArFunctor2C&lt;KeyPTU, double, double&gt;</a> myPos0CB;</div><div class="line">  <a class="code" href="classArFunctor2C.html">ArFunctor2C&lt;KeyPTU, double, double&gt;</a> myPos1CB;</div><div class="line">  <a class="code" href="classArFunctor2C.html">ArFunctor2C&lt;KeyPTU, double, double&gt;</a> myPos2CB;</div><div class="line">  <a class="code" href="classArFunctor2C.html">ArFunctor2C&lt;KeyPTU, double, double&gt;</a> myPos3CB;</div><div class="line">  <a class="code" href="classArFunctor2C.html">ArFunctor2C&lt;KeyPTU, double, double&gt;</a> myPos4CB;</div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">// the PTU</span></div><div class="line">  <a name="_a3"></a><a class="code" href="classArDPPTU.html">ArDPPTU</a> myPTU;</div><div class="line">  </div><div class="line"></div><div class="line">  <span class="comment">// whether the PTU has been inited or not</span></div><div class="line">  <span class="keywordtype">bool</span> myPTUInited;</div><div class="line">  <span class="comment">// pointer to the robot</span></div><div class="line">  <a class="code" href="classArRobot.html">ArRobot</a> *myRobot;</div><div class="line">  <span class="comment">// callback for the drive function</span></div><div class="line">  <a class="code" href="classArFunctorC.html">ArFunctorC&lt;KeyPTU&gt;</a> myDriveCB;</div><div class="line"></div><div class="line">  <a name="_a4"></a><a class="code" href="classArSerialConnection.html">ArSerialConnection</a> *mySerialConnection;</div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment">  Constructor, sets the robot pointer, and some initial values, also note the</span></div><div class="line"><span class="comment">  use of constructor chaining on myPTU and myDriveCB.</span></div><div class="line"><span class="comment">*/</span></div><div class="line">KeyPTU::KeyPTU(<a class="code" href="classArRobot.html">ArRobot</a> *robot, <span class="keyword">const</span> <span class="keywordtype">char</span> *port) :</div><div class="line">  myUpCB(<span class="keyword">this</span>, &amp;KeyPTU::up),</div><div class="line">  myDownCB(<span class="keyword">this</span>, &amp;KeyPTU::down),</div><div class="line">  myLeftCB(<span class="keyword">this</span>, &amp;KeyPTU::left),</div><div class="line">  myRightCB(<span class="keyword">this</span>, &amp;KeyPTU::right),</div><div class="line">  mySpaceCB(<span class="keyword">this</span>, &amp;KeyPTU::space),</div><div class="line">  myICB(<span class="keyword">this</span>, &amp;KeyPTU::i),</div><div class="line">  myPlusCB(<span class="keyword">this</span>, &amp;KeyPTU::plus),</div><div class="line">  myMinusCB(<span class="keyword">this</span>, &amp;KeyPTU::minus),</div><div class="line">  myGreaterCB(<span class="keyword">this</span>, &amp;KeyPTU::greater),</div><div class="line">  myLessCB(<span class="keyword">this</span>, &amp;KeyPTU::less),</div><div class="line">  myQuestionCB(<span class="keyword">this</span>, &amp;KeyPTU::question),</div><div class="line">  mySCB(<span class="keyword">this</span>, &amp;KeyPTU::status),</div><div class="line">  myACB(<span class="keyword">this</span>, &amp;KeyPTU::a),</div><div class="line">  myMCB(<span class="keyword">this</span>, &amp;KeyPTU::m),</div><div class="line">  myHCB(<span class="keyword">this</span>, &amp;KeyPTU::h),</div><div class="line">  myRCB(<span class="keyword">this</span>, &amp;KeyPTU::r),</div><div class="line">  myPos0CB(<span class="keyword">this</span>, &amp;KeyPTU::gotoPos, 0, 0),</div><div class="line">  myPos1CB(<span class="keyword">this</span>, &amp;KeyPTU::gotoPos, -90.0, 0.0),</div><div class="line">  myPos2CB(<span class="keyword">this</span>, &amp;KeyPTU::gotoPos, 90.0, 0.0),</div><div class="line">  myPos3CB(<span class="keyword">this</span>, &amp;KeyPTU::gotoPos, 0.0, -45.0),</div><div class="line">  myPos4CB(<span class="keyword">this</span>, &amp;KeyPTU::gotoPos, 0.0, 30.0),</div><div class="line">  myPTU(robot),</div><div class="line">  myDriveCB(<span class="keyword">this</span>, &amp;KeyPTU::drive),</div><div class="line">  mySerialConnection(NULL)</div><div class="line">{</div><div class="line">  mySerialConnection = <span class="keyword">new</span> <a class="code" href="classArSerialConnection.html">ArSerialConnection</a>;</div><div class="line">  <a name="a5"></a><a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a6"></a><a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;dpptuExample: connecting to DPPTU over computer serial port %s.&quot;</span>, port);</div><div class="line">  <span class="keywordflow">if</span>(mySerialConnection-&gt;open(port) != 0)</div><div class="line">  {</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a name="a7"></a><a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;dpptuExample: Error: Could not open computer serial port %s for DPPTU!&quot;</span>, port);</div><div class="line">    <a name="a8"></a><a class="code" href="classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(5);</div><div class="line">  }</div><div class="line">  myPTU.setDeviceConnection(mySerialConnection);</div><div class="line"></div><div class="line">  <span class="comment">// set the robot pointer and add the KeyPTU as user task</span></div><div class="line">  <a name="_a9"></a><a class="code" href="classArKeyHandler.html">ArKeyHandler</a> *keyHandler;</div><div class="line">  myRobot = robot;</div><div class="line">  <span class="keywordflow">if</span>(myRobot) myRobot-&gt;<a name="a10"></a><a class="code" href="classArRobot.html#ab3ed1a09a96c009802ed64bbc6c75325">addSensorInterpTask</a>(<span class="stringliteral">&quot;KeyPTU&quot;</span>, 50, &amp;myDriveCB);</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> ((keyHandler = <a name="a11"></a><a class="code" href="classAria.html#a5b8042b38b19d6a5d3cfbed4df483e67">Aria::getKeyHandler</a>()) == NULL)</div><div class="line">  {</div><div class="line">    keyHandler = <span class="keyword">new</span> <a class="code" href="classArKeyHandler.html">ArKeyHandler</a>;</div><div class="line">    <a name="a12"></a><a class="code" href="classAria.html#a9e5496a4ec2c379c8e18706922b57cc1">Aria::setKeyHandler</a>(keyHandler);</div><div class="line">    <span class="keywordflow">if</span>(myRobot) myRobot-&gt;attachKeyHandler(keyHandler);</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a name="a13"></a><a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<a name="a14"></a><a class="code" href="classArKeyHandler.html#a665246cd772590dd02ea299dd047899ca8a1d3905f01b5d27603bb0528912d341">ArKeyHandler::UP</a>, &amp;myUpCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;The key handler already has a key for up, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<a name="a15"></a><a class="code" href="classArKeyHandler.html#a665246cd772590dd02ea299dd047899cab3ecf95789d8f87444856e278393b4d9">ArKeyHandler::DOWN</a>, &amp;myDownCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;The key handler already has a key for down, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<a name="a16"></a><a class="code" href="classArKeyHandler.html#a665246cd772590dd02ea299dd047899ca4484301bbabab1fb37e72cbcd6e3e45b">ArKeyHandler::LEFT</a>, &amp;myLeftCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,  </div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for left, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<a name="a17"></a><a class="code" href="classArKeyHandler.html#a665246cd772590dd02ea299dd047899ca220c952e7e336650ee7b3e0905971ede">ArKeyHandler::RIGHT</a>, &amp;myRightCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,  </div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for right, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<a name="a18"></a><a class="code" href="classArKeyHandler.html#a665246cd772590dd02ea299dd047899cac7e8d225519fc03645b49532ad11c880">ArKeyHandler::SPACE</a>, &amp;mySpaceCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for space, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;i&#39;</span>, &amp;myICB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;i&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;+&#39;</span>, &amp;myPlusCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;+&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;-&#39;</span>, &amp;myMinusCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;-&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;&gt;&#39;</span>, &amp;myGreaterCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;&gt;&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;&lt;&#39;</span>, &amp;myLessCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;&lt;&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;?&#39;</span>, &amp;myQuestionCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;?&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;s&#39;</span>, &amp;mySCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;S&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;a&#39;</span>, &amp;myACB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;A&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;z&#39;</span>, &amp;myPos0CB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;Z&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;m&#39;</span>, &amp;myMCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;M&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;h&#39;</span>, &amp;myHCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;H&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;r&#39;</span>, &amp;myRCB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>,</div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;R&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line"></div><div class="line"></div><div class="line">  <span class="keywordflow">if</span>(!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;Z&#39;</span>, &amp;myPos0CB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, </div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;Z&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span>(!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;1&#39;</span>, &amp;myPos1CB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, </div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;1&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span>(!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;2&#39;</span>, &amp;myPos2CB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, </div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;2&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span>(!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;3&#39;</span>, &amp;myPos3CB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, </div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;3&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span>(!keyHandler-&gt;<a class="code" href="classArKeyHandler.html#ad5442ebb21cd242ab168e94686e06759">addKeyHandler</a>(<span class="charliteral">&#39;4&#39;</span>, &amp;myPos4CB))</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, </div><div class="line"><span class="stringliteral">&quot;The key handler already has a key for &#39;4&#39;, keydrive will not work correctly.&quot;</span>);</div><div class="line"></div><div class="line">  <span class="comment">// initialize some variables</span></div><div class="line">  myReset = <span class="keyword">false</span>;</div><div class="line">  myInit = <span class="keyword">true</span>;</div><div class="line">  myDesiredPanPos = 0;</div><div class="line">  myDesiredTiltPos = 0;</div><div class="line">  myPosIncrement = 1;</div><div class="line">  mySlewIncrement = 1;</div><div class="line">  myPTUInited = <span class="keyword">false</span>;</div><div class="line">  myMonitor = <span class="keyword">false</span>;</div><div class="line"></div><div class="line">}</div><div class="line"></div><div class="line">KeyPTU::~KeyPTU() </div><div class="line">{</div><div class="line">  <span class="keywordflow">if</span>(mySerialConnection)</div><div class="line">  {</div><div class="line">    myPTU.setDeviceConnection(NULL);</div><div class="line">    <span class="keyword">delete</span> mySerialConnection;</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::left(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myDesiredPanPos += myPosIncrement;</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (myDesiredPanPos &gt; myPTU.getMaxPosPan())</div><div class="line">    myDesiredPanPos = myPTU.getMaxPosPan();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::right(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myDesiredPanPos -= myPosIncrement;</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (myDesiredPanPos &lt; myPTU.getMaxNegPan())</div><div class="line">    myDesiredPanPos = myPTU.getMaxNegPan();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::up(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myDesiredTiltPos += myPosIncrement;</div><div class="line"> </div><div class="line">  <span class="keywordflow">if</span> (myDesiredTiltPos &gt; myPTU.getMaxPosTilt())</div><div class="line">    myDesiredTiltPos = myPTU.getMaxPosTilt();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::down(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myDesiredTiltPos -= myPosIncrement;</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (myDesiredTiltPos &lt; myPTU.getMaxNegTilt())</div><div class="line">    myDesiredTiltPos = myPTU.getMaxNegTilt();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::space(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myReset = <span class="keyword">true</span>;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::i(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myInit = <span class="keyword">true</span>;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::plus(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  mySlew += mySlewIncrement;</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (mySlew &gt; myPTU.getMaxPanSlew())</div><div class="line">    mySlew = myPTU.getMaxPanSlew();</div><div class="line"></div><div class="line">  status();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::minus(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  mySlew -= mySlewIncrement;</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (mySlew &lt; myPTU.getMinPanSlew())</div><div class="line">    mySlew = myPTU.getMinPanSlew();</div><div class="line"></div><div class="line">  status();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::greater(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myPosIncrement += POS_INCREMENT_ADJUSTMENT;</div><div class="line">  </div><div class="line">  <span class="keywordflow">if</span> (myPosIncrement &gt; myPTU.getMaxPosPan())</div><div class="line">    myPosIncrement = myPTU.getMaxPosPan();</div><div class="line"></div><div class="line">  status();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::less(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myPosIncrement -= POS_INCREMENT_ADJUSTMENT;</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (myPosIncrement &lt; 0)</div><div class="line">    myPosIncrement = 0;</div><div class="line"></div><div class="line">  status();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::a(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myPTU.awaitExec();   </div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;AwaitExecution command sent&quot;</span>);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::gotoPos(<span class="keywordtype">double</span> p, <span class="keywordtype">double</span> t)</div><div class="line">{</div><div class="line">  myDesiredPanPos = p;</div><div class="line">  myDesiredTiltPos = t;</div><div class="line">  status();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::question(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;\r\nCommands:\r\n_________________\r\n&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;UP,DOWN    -- tilt up/down by one positional increment&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;LEFT,RIGHT -- pan left/right by one positional increment&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;SPACE      -- perform reset calibration&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;I          -- initialize PTU to default settings&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;&lt;,&gt;        -- increase/decrease the posIncrement by %f degree(s)&quot;</span>, POS_INC_ADJUSTMENT);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;+,-        -- increase/decrease the speed by 1 degree/sec&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;A          -- awaits the completion of last issued positional command&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;R          -- change pan/tilt movements to relative or absolute movements&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Z          -- move pan and tilt axes to zero&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;1          -- move to stored position 1 (-90, 0)&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;2          -- move to stored position 2 (90, 0)&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;3          -- move to stored position 3 (0, -45)&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;4          -- move to stored position 4 (0, 30)&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;M          -- Enter or Exit monitor (continuous scan) mode&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;H          -- Halt all motion&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;S          -- print current variable values&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;ESC        -- exit program&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;\r\n&quot;</span>);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::status(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;\r\nStatus:\r\n_________________\r\n&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Last Pan Command      = %.1f deg&quot;</span>, myPTU.getLastPanRequest());</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Last Tilt Command      = %.1f deg&quot;</span>, myPTU.getLastTiltRequest());</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Current Pan Position  = %.1f deg&quot;</span>, myPTU.getPan());</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Current Tilt Position = %.1f deg&quot;</span>, myPTU.getTilt());</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Pan Slew Rate         = %d deg/sec&quot;</span>, myPTU.getPanSlew());</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Tilt Slew Rate        = %d deg/sec&quot;</span>, myPTU.getTiltSlew());</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Position Increment    = %d deg&quot;</span>, myPosIncrement);</div><div class="line">  <span class="keywordflow">if</span> (myAbsolute)</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Positional-movements using absolute commands&quot;</span>);</div><div class="line">  <span class="keywordflow">else</span></div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Positional-movements using relative commands&quot;</span>);</div><div class="line">  <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;\r\n&quot;</span>);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::m(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  <span class="keywordflow">if</span> (!myMonitor)</div><div class="line">  {</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Entering Monitor mode - hit &#39;M&#39; to disable&quot;</span>);</div><div class="line">    myMonitor = <span class="keyword">true</span>;</div><div class="line">    myPTU.initMon(-60,60,30,-30);</div><div class="line">  }</div><div class="line">  <span class="keywordflow">else</span></div><div class="line">  {</div><div class="line">    myPTU.blank();  <span class="comment">//Blank packet exits monitor mode</span></div><div class="line">    myMonitor = <span class="keyword">false</span>;</div><div class="line">  }</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::h(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  myPTU.haltAll();</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">void</span> KeyPTU::r(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  <span class="keywordflow">if</span> (!myAbsolute)</div><div class="line">  {</div><div class="line">    myAbsolute = <span class="keyword">true</span>;</div><div class="line">  }</div><div class="line">  <span class="keywordflow">else</span></div><div class="line">  {</div><div class="line">    myAbsolute = <span class="keyword">false</span>;</div><div class="line">  }</div><div class="line">  status();</div><div class="line">}</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// the important function</span></div><div class="line"><span class="keywordtype">void</span> KeyPTU::drive(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line"></div><div class="line">  <span class="comment">// if the PTU isn&#39;t initialized, initialize it here... it has to be </span></div><div class="line">  <span class="comment">// done here instead of above because it needs to be done when the </span></div><div class="line">  <span class="comment">// robot is connected</span></div><div class="line">  <span class="keywordflow">if</span> (!myPTUInited)</div><div class="line">  {</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Initializing ArDPPTU...&quot;</span>);</div><div class="line">    myPTU.init();</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Resetting PTU and performing self-calibration...&quot;</span>);</div><div class="line">    myPTU.resetCalib();</div><div class="line">    myPTU.awaitExec(); <span class="comment">// DPPTU will wait for self-calibration to end before executing the following commands (though they will still be sent)</span></div><div class="line">    mySlew = myPTU.getPanSlew(); <span class="comment">//uses only pan slew rate</span></div><div class="line">    myPTU.awaitExec();</div><div class="line">    myPTUInited = <span class="keyword">true</span>;</div><div class="line">    myInit = <span class="keyword">false</span>;</div><div class="line">    myAbsolute = <span class="keyword">true</span>;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (myInit == <span class="keyword">true</span>)  <span class="comment">// User hit initialization key</span></div><div class="line">  {</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Initializing PTU...&quot;</span>);</div><div class="line">    myPTU.init();</div><div class="line">    myInit = <span class="keyword">false</span>;</div><div class="line">    myDesiredPanPos = myPTU.getPan();</div><div class="line">    myDesiredTiltPos = myPTU.getTilt();</div><div class="line">    mySlew = myPTU.getPanSlew(); <span class="comment">//uses only pan slew rate</span></div><div class="line">    myReset = <span class="keyword">false</span>;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">if</span> (myReset == <span class="keyword">true</span>) <span class="comment">// User hit reset key</span></div><div class="line">  {</div><div class="line">    <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;Resetting PTU and performing self-calibration...&quot;</span>);</div><div class="line">    myPTU.resetCalib();</div><div class="line">    myPTU.awaitExec();</div><div class="line">    myDesiredPanPos = myPTU.getPan();</div><div class="line">    myDesiredTiltPos = myPTU.getTilt();</div><div class="line">    myReset = <span class="keyword">false</span>;</div><div class="line">  }</div><div class="line">  <span class="keywordflow">else</span>   <span class="comment">// User did nothing, or hit a key that changed myDesiredPanPos, myDesiredTiltPos, or mySlew (so request PTU to move if those changed since last request)</span></div><div class="line">  {</div><div class="line"></div><div class="line">    <span class="comment">// Some PTUs can determine their current position (with encoders, etc) and return that.</span></div><div class="line">    <span class="comment">// canGetRealPanTilt() will return true in this case, and getPan() and</span></div><div class="line">    <span class="comment">// getTilt() will return those received values.  Otherwise, getPan() and</span></div><div class="line">    <span class="comment">// getTilt() return the last commanded values.  getLastPanRequest() and</span></div><div class="line">    <span class="comment">// getLastTiltRequest() will always return the last commanded values sent by</span></div><div class="line">    <span class="comment">// ArDPPTU (so in the case that canGetRealPanTilt() is false, getPan() and</span></div><div class="line">    <span class="comment">// getTilt() return the same pair of values as getLastPanRequest() and</span></div><div class="line">    <span class="comment">// getLastTiltRequest().  ArDPPTU::canGetRealPanTilt() is initialally false,</span></div><div class="line">    <span class="comment">// but once the first set of pan and tilt positions is read back from the</span></div><div class="line">    <span class="comment">// PTU device, it becomes true.  </span></div><div class="line">    <span class="keywordflow">if</span>(myPTU.canGetRealPanTilt())</div><div class="line">      printf(<span class="stringliteral">&quot;Position (%.1f deg, %.1f deg)     [Incr. %d deg]     Press ? for help  \r&quot;</span>, myPTU.getPan(), myPTU.getTilt(), myPosIncrement);</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">      printf(<span class="stringliteral">&quot;Requested (%.1f deg, %.1f deg)     [Incr. %d deg]     Press ? for help  \r&quot;</span>, myPTU.getPan(), myPTU.getTilt(), myPosIncrement);</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (myDesiredPanPos != myPTU.getLastPanRequest())</div><div class="line">    {</div><div class="line">      <span class="keywordflow">if</span> (myAbsolute)</div><div class="line">        myPTU.pan(myDesiredPanPos);</div><div class="line">      <span class="keywordflow">else</span></div><div class="line">        myPTU.panRel(myDesiredPanPos - myPTU.getPan());</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (myDesiredTiltPos != myPTU.getLastTiltRequest())</div><div class="line">    {</div><div class="line">      <span class="keywordflow">if</span> (myAbsolute)</div><div class="line">        myPTU.tilt(myDesiredTiltPos);</div><div class="line">      <span class="keywordflow">else</span></div><div class="line">        myPTU.tiltRel(myDesiredTiltPos - myPTU.getTilt());</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (mySlew != myPTU.getPanSlew())</div><div class="line">    {</div><div class="line">      myPTU.panSlew(mySlew);</div><div class="line">      myPTU.tiltSlew(mySlew);</div><div class="line">    }</div><div class="line"></div><div class="line">  }</div><div class="line"></div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) </div><div class="line">{</div><div class="line">    <a name="a19"></a><a class="code" href="classAria.html#ad99c16b5d947229d9f8e1c5b2d4cdd73">Aria::init</a>();</div><div class="line">    <a name="_a20"></a><a class="code" href="classArArgumentParser.html">ArArgumentParser</a> parser(&amp;argc, argv);</div><div class="line">    parser.<a name="a21"></a><a class="code" href="classArArgumentParser.html#a501694b62a7f8b0c3cadd84aeafe1b35">loadDefaultArguments</a>();</div><div class="line">    <a class="code" href="classArRobot.html">ArRobot</a> *userobot = NULL;</div><div class="line">    <a class="code" href="classArRobot.html">ArRobot</a> robot;</div><div class="line">    <a name="_a22"></a><a class="code" href="classArRobotConnector.html">ArRobotConnector</a> robotConnector(&amp;parser, &amp;robot);</div><div class="line">    robotConnector.<a name="a23"></a>setResetOldConnection(<span class="keyword">false</span>);</div><div class="line">    robot.<a name="a24"></a>setAsyncConnectSyncPacketRetries(2);</div><div class="line">    <span class="keywordflow">if</span>(!robotConnector.<a name="a25"></a><a class="code" href="classArRobotConnector.html#ab192ac393d9cc1e5b61b1a82b08d085d">connectRobot</a>())</div><div class="line">    {</div><div class="line">      <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a012daf6573594f91242f8dd7c02eb74b">ArLog::Terse</a>, <span class="stringliteral">&quot;dpptuExample: Could not connect to the robot.&quot;</span>);</div><div class="line">      <span class="keywordflow">if</span>(parser.<a name="a26"></a><a class="code" href="classArArgumentParser.html#ac3889cbdfa862031c51bf80e06954914">checkHelpAndWarnUnparsed</a>())</div><div class="line">      {</div><div class="line">        userobot = NULL;</div><div class="line">      }</div><div class="line">    }</div><div class="line">    <span class="keywordflow">else</span></div><div class="line">    {</div><div class="line">      <a class="code" href="classArLog.html#a43a8b3789126c818f390f24bdbceccce">ArLog::log</a>(<a class="code" href="classArLog.html#ac8cc0fb3aa323ab2a1c21340fdd1dce3a7040faf60eeb155eaa85d439b1066ca1">ArLog::Normal</a>, <span class="stringliteral">&quot;dpptuExample: Connected to robot.&quot;</span>);</div><div class="line">      robot.<a name="a27"></a><a class="code" href="classArRobot.html#a3c3d878cfd11a2ef91230005a83bfcaa">runAsync</a>(<span class="keyword">true</span>);</div><div class="line">      userobot = &amp;robot;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (!<a name="a28"></a><a class="code" href="classAria.html#a1b090c01d88bb420b8cf8e0384d25ee1">Aria::parseArgs</a>() || !parser.<a class="code" href="classArArgumentParser.html#ac3889cbdfa862031c51bf80e06954914">checkHelpAndWarnUnparsed</a>())</div><div class="line">    {</div><div class="line">      <a name="a29"></a><a class="code" href="classAria.html#a10d71f3d4d0cf7f38c58a1f749f64a42">Aria::logOptions</a>();</div><div class="line">      <a class="code" href="classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(1);</div><div class="line">    }</div><div class="line"></div><div class="line">  <span class="comment">// an object for keyboard control, class defined above, this also adds itself as a user task</span></div><div class="line">  KeyPTU ptudriver(userobot, userobot?SERIAL_PORT_WITH_ROBOT:SERIAL_PORT_WITHOUT_ROBOT);</div><div class="line"></div><div class="line"></div><div class="line">  <span class="comment">// turn off the sonar</span></div><div class="line">  <span class="keywordflow">if</span>(userobot)</div><div class="line">    robot.<a name="a30"></a><a class="code" href="classArRobot.html#aceef80a6274fb34aafcc422e4b1778c1">comInt</a>(<a name="a31"></a><a class="code" href="classArCommands.html#a9a31f904a95bbc31d8b33c6637100cc4a891b21e6cabc8a2296c8bceca20be779">ArCommands::SONAR</a>, 0);</div><div class="line"></div><div class="line">  printf(<span class="stringliteral">&quot;Press &#39;?&#39; for available commands\r\n&quot;</span>);</div><div class="line"></div><div class="line">  <span class="comment">// run, if we lose connection to the robot, exit</span></div><div class="line">  <span class="keywordflow">if</span>(userobot)</div><div class="line">    robot.<a name="a32"></a><a class="code" href="group__easy.html#ga95201be7c39b521983b51e6f5d9303e4">waitForRunExit</a>();</div><div class="line">  <span class="keywordflow">else</span></div><div class="line">  {</div><div class="line">      <span class="keywordflow">while</span>(<span class="keyword">true</span>) </div><div class="line">      {</div><div class="line">        <span class="keywordflow">if</span>(<a class="code" href="classAria.html#a5b8042b38b19d6a5d3cfbed4df483e67">Aria::getKeyHandler</a>()) <a class="code" href="classAria.html#a5b8042b38b19d6a5d3cfbed4df483e67">Aria::getKeyHandler</a>()-&gt;<a name="a33"></a><a class="code" href="classArKeyHandler.html#a8b2b9cdf792f36ca199efe5a7109bc73">checkKeys</a>();</div><div class="line">        ptudriver.drive();</div><div class="line">        <a name="a34"></a><a class="code" href="group__easy.html#ga4dfb878a3f9123b8dd96ae05b2fd94cb">ArUtil::sleep</a>(100);</div><div class="line">      }</div><div class="line">  }</div><div class="line"></div><div class="line">  <a class="code" href="classAria.html#a6abc3d39b3e9548063bb8e78375acc17">Aria::exit</a>(0);</div><div class="line">}</div><div class="line"></div></div><!-- fragment --> </div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
